package jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;

public class PreparedStmt {
	public static void main(String[] args) {

		try {
			Class.forName("oracle.jdbc.driver.OracleDriver");
			// Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

			Connection con = DriverManager.getConnection(
					"jdbc:oracle:thin:@10.23.0.100:1521:esgdb10", "scott",
					"tiger");

			/*
			 * Connection con = DriverManager.getConnection(
			 * "jdbc:oracle:thin:@10.23.12.245:1521:orcl", "scott", "tiger");
			 */
			/*
			 * Connection con = DriverManager.getConnection( "jdbc:odbc:myCon",
			 * "scott", "tiger");
			 */

			System.out.println("Driver Connected successfully.");

			PreparedStatement pstmt = con
					.prepareStatement("INSERT INTO myTable VALUES(?,?,?)");
			pstmt.setInt(1, 100);
			pstmt.setString(2, "Raj");
			pstmt.setFloat(3, 25000f);

			pstmt.executeUpdate();
			System.out.println("Record inserted successfully.");
			pstmt.close();
			con.close();
		} catch (Exception e) {
			System.out.println(e.toString());
		}
	}
}
